Home:ALL Converter>Why is 5[a] valid and does not generate an error of invalid identifier?

Why is 5[a] valid and does not generate an error of invalid identifier?

Ask Time:2015-12-11T20:32:30         Author:Paul Ogilvie

Json Formatter

In With arrays, why is it the case that a[5] == 5[a]? it is explained that the [] operator in a[5] is defined as *(a + 5) and because + is commutative, 5[a] means *(5 + a) and so the two expressions refer to the same memory location. Fine.

However, C also defines in 6.4.2.1 that an identifier cannot start with a digit. In 5[a] the array identifier is 5 which is not a valid identifier. Why does 5[a] not generate an error about an invalid identifier?

Author:Paul Ogilvie,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/34223697/why-is-5a-valid-and-does-not-generate-an-error-of-invalid-identifier
yy